<?php

/*

  Action	$0 + 1 potion

  Trash a card from your hand.  If it is an…
  Action card, gain a Duchy; Treasure card, gain a Transmute; Victory card, gain a Gold.

 */

class Transmute extends Card implements iAction, iKingdom, iAlchemy {

    public function __construct() {
        $price = new Price(0, 1);
        parent::__construct("Transmute", $price);
        $this->undoPlay = false;
        $this->undoBuy = true;
    }

    public function getDescription() {
        return array(
            "Trash a card from your hand.  If it is an… Action card, gain a Duchy; Treasure card, gain a Transmute; Victory card, gain a Gold.");
    }
    public function play(Game $game, $isRealCard) {
        $playHand = $game->getPlayHand();
        if (sizeof($playHand) > 0) {
            $playHand = getUniqueCards($playHand);
			if (sizeof($playHand) > 1) {
				$output = MySocket::GetUserReply($game,  Input_ChooseOne, $playHand, 1, 1, null, "Choose card to trash");
				$card_name = $output[0];
			}
			else {
				$card_name = $playHand[0];
			}
			
            ScreenDisplay::addScreenMessage($game, true, "trash ".  nicePrint($card_name), "trashes ". ScreenDisplay::$LMSG);
            $card = $game->moveCardFromPileToPile($card_name, PlayHand, Trash);

            $new_card_name = "";

            if ($card instanceof iTreasure) {
                $new_card_name = "Transmute";
            }
            if ($card instanceof iVictory) {
                $new_card_name = "Gold";
            }
            if ($card instanceof iAction) {
                $new_card_name = "Duchy";
            }

            $new_card = $game->moveCardFromPileToPile($new_card_name, BoardCards, DiscardPile);
            ScreenDisplay::addScreenMessage($game, false, " and gain  ".  nicePrint($new_card), " and gains ". ScreenDisplay::$LMSG);
        }
		else {
			ScreenDisplay::addScreenMessage($game, true, "trash  nothing", "trashes nothing");
		}
        $game->cardActionFinished();
        return true;
    }
    
        public function boardSetup(Game $game) {
        $game->addPotion();
        return true;
    }
}

?>